<?php

/**
 * @author Djordje Zeljic
 * Date: Jun 2, 2010 9:31:44 AM
 */
class products_m extends Model {

    function products_m () {
        parent::Model();
    }// construct of products_m

    function create(){

    }

    function read($id){
        $data = array(); // storage for all data for return
        $row = $this->db->select('*')
                ->from('products')
                ->join('productcategory','productcategory.id = products.productcategory','left')
                ->where('products.id',$id)
                ->get()->row_array();
        switch ($row['productCategory']){
            case 1 :
                $data['productdescription'] = $this->db->select('*')
                    ->from('excursions')
                    ->join('transports','transports.id = excursions.transportsid','left')
                    ->where('excursions.id',$row['productdescriptionid'])
                    ->get()->row_array();
                break;
        }
        $data['product'] = $row;
        // now return all data about product
        return $data;
    }
    
}
?>